#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
//头文件
#include<QTcpSocket>
#include<QMetaEnum>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

/**
 * @brief 用QTcpSocket，实现tcp通信客户端
 */
class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void   on_btnConnect_clicked();
    void   on_btnSend_clicked();
    void   onConnected();
    void   onDisconnected();
    void   onStateChanged(QAbstractSocket::SocketState);
    void   onError(QAbstractSocket::SocketError);
    void   onReadyRead();

private:
    Ui::Widget *ui;
    QTcpSocket  m_tcpsocket;
    bool m_connected = false;

};
#endif // WIDGET_H
